﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using Box.Entities;
using Box.Repository.Mapping;

namespace Box.Repository
{
    public  class BoxContext:DbContext
    {
        static BoxContext()
        {
            Database.SetInitializer<BoxContext>
            (
              null
                //new DatabaseInicializer()
                //new DropCreateDatabaseIfModelChanges<BoxContext>()
                //new DropCreateDatabaseAlways<BoxContext>()
                //new CreateDatabaseIfNotExists<BoxContext>()

                );
        }
        public BoxContext()
            : base("Name=BoxContext")
        {
            this.Configuration.LazyLoadingEnabled = false;
            this.Configuration.ProxyCreationEnabled = false;
            this.Configuration.AutoDetectChangesEnabled = false;

        }

        public DbSet<Categoria> Categorias { get; set; }
        public DbSet<Cliente> Clientes { get; set; }
        public DbSet<Compra> Compras { get; set; }
        public DbSet<DetalleCompra> DetalleCompras { get; set; }
        public DbSet<DetalleVenta> DetalleVentas { get; set; }
        public DbSet<SerieComprobante> SerieComprobantes { get; set; }

        public DbSet<Insumo> Insumos { get; set; }
        
        public DbSet<Pagos> Pagos { get; set; }
        public DbSet<Producto> Productos { get; set; }
        public DbSet<Proveedor> Proveedores { get; set; }
        public DbSet<TipoProducto> TipoProductos { get; set; }
        public DbSet<Venta> Ventas { get; set; }
        public DbSet<DetalleCatalogoProductos> DetalleCatalogoProductos { get; set; }
        public DbSet<Marca> Marcas { get; set; }
        public DbSet<TipoDocumento> TipoDocumentos { get; set; }
        public DbSet<Ubigeo> Ubigeos { get; set; }
        public DbSet<PagoCompra> PagoCompras { get; set; }
        public DbSet<TasaCambio> TasaCambios { get; set; }
        public DbSet<NotaPedido> NotaPedidos { get; set; }
        public DbSet<DetalleNotaPedido> DetalleNotaPedidos { get; set; }
        public DbSet<Banco> Bancos { get; set; }      


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new CategoriaMap());
            modelBuilder.Configurations.Add(new ClienteMap());
            modelBuilder.Configurations.Add(new ComprasMap());
            modelBuilder.Configurations.Add(new DetalleCompraMap());
            modelBuilder.Configurations.Add(new SerieComprabanteMap());
            modelBuilder.Configurations.Add(new DetalleVentaMap());

            modelBuilder.Configurations.Add(new InsumosMap());

            modelBuilder.Configurations.Add(new PagosMap());
            modelBuilder.Configurations.Add(new ProductoMap());
            modelBuilder.Configurations.Add(new ProveedorMap());
            modelBuilder.Configurations.Add(new TipoProductoMap());
            modelBuilder.Configurations.Add(new VentasMap());
            modelBuilder.Configurations.Add(new DetalleCatalogoProductoMap());
            modelBuilder.Configurations.Add(new MarcaMap());
            modelBuilder.Configurations.Add(new TipoDocumentoMap());
            modelBuilder.Configurations.Add(new UbigeoMap());
            modelBuilder.Configurations.Add(new PagoCompraMap());
            modelBuilder.Configurations.Add(new TasaCambioMap());
            modelBuilder.Configurations.Add(new NotaPedidoMap());
            modelBuilder.Configurations.Add(new DetalleNotaPedidoMap());
            modelBuilder.Configurations.Add(new BancoMap());

            
        }
    }

    #region llenado de datos en bd

    #endregion
}
